#ifndef HASHARCHIVO_H
#define HASHARCHIVO_H

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

const int endian_const = 1;
#define is_bigendian() ( (*(char*)&endian_const) == 0 )
#define SHA1CircularShift(bits,word) \
                ((((word) << (bits)) & 0xFFFFFFFF) | \
                ((word) >> (32-(bits))))

using namespace std;

typedef struct SHA1Context
{
    unsigned Message_Digest[5];

    unsigned Length_Low;
    unsigned Length_High;

    unsigned char Message_Block[64];
    int Message_Block_Index;

    int Computed;
    int Corrupted;
} SHA1Context;


class HashArchivo {
    public:
        string GenerarHash( string filename );
    private:
        void SHA1Reset(SHA1Context *);
        int SHA1Result(SHA1Context *);
        void SHA1Input( SHA1Context *, const unsigned char *, unsigned);
        void SHA1ProcessMessageBlock(SHA1Context *);
        void SHA1PadMessage(SHA1Context *);
        int bin_to_base64(char *src,int src_len,char* ptr);
        unsigned int IntFixEndiannes (char *c);
};

#endif /* HASHARCHIVO_H */
